import {loginApi} from '@utils/api/user'
window.addEventListener('DOMContentLoaded',(req,res)=>{
    document.querySelector('#loginBtn').addEventListener('click',async()=>{
        let username=document.querySelector("#username").value
        let password=document.querySelector("#password").value
        let user={username,password}
        const {code,message,token}=await loginApi(user)
        if(code){
            alert(message)
            //保存token到localStorage中
            localStorage.setItem('token',token)
            window.location.href="/"
        }else{
            alert(message)
        }
    })
})